package com.zhang;

import org.junit.Test;
import redis.clients.jedis.Jedis;

import java.util.List;

public class JedisDemo1 {
    //1、设置ip地址和端口
    Jedis jedis=new Jedis("127.0.0.1",6379);




    /**
     * 测试字符串
     */
    @Test
    public  void dome1()
    {

//      2.保存数据
        jedis.set("json1","{" +
                "    dataContent:[" +
                "        {\n" +
                "            \"hospitalId\":49906834," +
                "            \"provider_id\":49906834,\n" +
                "            \"insuranceName\":\"\",\n" +
                "            \"insuranceCertNo\":\"\",\n" +
                "            \"insuranceCertType\":\"\",\n" +
                "            \"startDate\":\"\",\n" +
                "            \"medicalType\":\"0\",\n" +
                "            \"serviceClassification\":\"0\",\n" +
                "            \"endDate\":\"\",\n" +
                "            \"medicalNum\":\"\",\n" +
                "            \"medicalCardNum\":\"\",\n" +
                "            \"outpatientNo\":\"201808013617\",\n" +
                "            \"inHospitalNum\":\"\"\n" +
                "        }\n" +
                "    ]\n" +
                "}");
        System.out.println(jedis.get("json1"));
//        释放支援
        jedis.close();
    }

    /**
     * 测试列
     */
    @Test
    public  void dome2(){
        jedis.lpush("jedis1","1");
        jedis.lpush("jedis1","2");
        jedis.lpush("jedis1","3");
        jedis.lpush("jedis1","4");
        jedis.lpush("jedis1","5");
        jedis.lpush("jedis1","6");
        List<String> list = jedis.lrange("jedis1", 0 ,5);
        for(int i = 0; i<list.size(); i++) {
            System.out.println("Stored string in redis:: "+list.get(i));
        }
    }
}
